//用于全局忽略某些文件或目录，使它们不受 ESLint 检查
import { globalIgnores } from 'eslint/config';
// 负责 Vue 单文件组件中的 TypeScript 检查
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript';
import pluginVue from 'eslint-plugin-vue';
// 这是 Vue 官方提供的一个配置，专门用于 Vue 项目，跳过 ESLint 中与格式化相关的规则 ，让 Prettier 专门负责代码格式化，禁用 ESLint 中与 Prettier 冲突的规则，安装此插件后不用再安eslint-config-prettier
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting';

import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended';

export default defineConfigWithVueTs(
    {
        name: 'app/files-to-lint',
        files: ['**/*.{ts,mts,tsx,vue}']
    },
    globalIgnores([
        '**/dist/**',
        '**/dist-ssr/**',
        '**/coverage/**',
        'node_modules',
        'src/components/Login/sms-verifition-input/**',
        'src/lib/**',
        'public/**'
    ]),
    pluginVue.configs['flat/essential'],
    vueTsConfigs.recommended,
    skipFormatting,
    {
        name: 'app/custom-rules',
        rules: {
            // 简化生产环境判断逻辑
            'no-console': 'off',
            'no-debugger': 'off',
            'key-spacing': [
                'error',
                {
                    beforeColon: false,
                    afterColon: true
                }
            ],
            'space-in-parens': ['error', 'never'],
            'object-curly-spacing': ['error', 'always'],
            'object-curly-newline': [
                'error',
                {
                    minProperties: 5,
                    multiline: true,
                    consistent: true
                }
            ],
            'vue/object-curly-spacing': 'off',
            'max-len': 'off',
            'no-multi-spaces': 'error',
            'no-return-assign': 'off',
            semi: ['error', 'always'],
            eqeqeq: 'error',
            'jsx-quotes': ['off', 'prefer-single'],
            'import/prefer-default-export': 'off',
            'import/extensions': 'off',
            'import/no-unresolved': 'off',
            'no-multiple-empty-lines': [
                'error',
                {
                    max: 2,
                    maxEOF: 1
                }
            ],
            'no-param-reassign': 'off',
            'vue/eqeqeq': ['error', 'always'],
            'vue/html-end-tags': 'error',
            'vue/no-spaces-around-equal-signs-in-attribute': 'error',
            'vue/multi-word-component-names': 'off',
            'vue/no-template-shadow': 'error',
            'vue/require-prop-types': 'error',
            'vue/require-explicit-emits': 'error',
            'vue/mustache-interpolation-spacing': ['error', 'always'],
            'vue/no-multi-spaces': [
                'error',
                {
                    ignoreProperties: false
                }
            ],
            'vue/html-closing-bracket-newline': [
                'error',
                {
                    singleline: 'never',
                    multiline: 'always'
                }
            ],
            'vue/html-self-closing': 'off',
            'vue/block-lang': 'off',
            'vue/html-indent': [
                'error',
                2,
                {
                    attribute: 1,
                    baseIndent: 1,
                    closeBracket: 0,
                    alignAttributesVertically: true,
                    ignores: ['VExpressionContainer']
                }
            ],
            'vue/html-closing-bracket-spacing': [
                'error',
                {
                    startTag: 'never',
                    endTag: 'never',
                    selfClosingTag: 'always'
                }
            ],
            'vue/max-attributes-per-line': [
                'error',
                {
                    singleline: 3,
                    multiline: 1
                }
            ],
            'vue/attribute-hyphenation': 'off',
            '@typescript-eslint/no-shadow': 'off',
            '@typescript-eslint/no-explicit-any': 'off',
            '@typescript-eslint/no-unused-vars': 'warn',
            '@typescript-eslint/ban-ts-comment': 'off',
            '@typescript-eslint/indent': 'off',
            '@typescript-eslint/no-empty-object-type': 'off'
        }
    },
    eslintPluginPrettierRecommended //新增配置
);
